﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Web.UI;
using WinnerCMS.BLL.PageFactory;
using WinnerCMS.BLL.PageFactory.TagModule;
using WinnerCMS.Common;

namespace WinnerCMS.WebFactory
{
    public class Index : PublicPage
    {

        #region 重写事件
        override protected void OnInit(EventArgs e)
        {
            InitializeComponent();
            base.OnInit(e);
        }
        private void InitializeComponent()
        { 
        }
        #endregion
         
        #region 重写Render
        protected override void Render(HtmlTextWriter writer)
        {
            StringBuilder winner = new StringBuilder();
            using (TextWriter tempWriter = new StringWriter())
            {
                base.Render(new HtmlTextWriter(tempWriter));
                winner.Append(tempWriter.ToString());
            }

            IList<string> matchresult;

            matchresult = TagEngine.TagCollection(winner.ToString(), "FriendLink");
            foreach (string nextmatch in matchresult)
            {
                winner.Replace(nextmatch, PageCommon.FriendLink(nextmatch));
            }



            #region 通用模型标签
            matchresult = TagEngine.TagCollection(winner.ToString(), "Slide");
            foreach (string nextmatch in matchresult)
            {
                winner.Replace(nextmatch, PageCommon.Slide(nextmatch));
            }
          
         
            #endregion
              
 
            if (Request["Method"] != null)
            {
                string path = StaticFilePath.IndexUrl(true);
                new FileIO().WriterFile(HttpServer.MapPath(path), winner.ToString());
            }
            else
            {
                writer.Write(winner.ToString());
            }

        }
        #endregion

    }
}